<?php

function getImage($mime) {

    $imageDir = "../images";

    $array = array(
        /* doc */ "application/vnd.openxmlformats-officedocument.wordprocessingml.document" => "$imageDir/doc.png",
        /* docx */ "application/msword" => "$imageDir/doc.png",
        /* xsl */ "application/octet-stream" => "$imageDir/xls.png",
        /* xsl */ "application/vnd.ms-excel" => "$imageDir/xls.png",
        /* xslx */ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" => "$imageDir/xls.png",
        /* ppt */ "application/vnd.ms-powerpoint" => "$imageDir/ppt.png",
        /* pptx */ "application/vnd.openxmlformats-officedocument.presentationml.presentation" => "$imageDir/ppt.png",
        /* rtf */ "text/rtf" => "$imageDir/text.png",
        /* rtxt */ "text/plain" => "$imageDir/text.png",
        /* jpeg */ "image/jpeg" => "$imageDir/image.png",
        /* gif */ "image/gif" => "$imageDir/image.png",
        /* png */ "image/png" => "$imageDir/image.png",
        /* pdf */ "application/pdf" => "$imageDir/pdf.png",
        /* file */ "file" => "$imageDir/file.png"
        
        /* doc  "application/vnd.openxmlformats-officedocument.wordprocessingml.document" => "$imageDir/ext/file-doc.png",
        /* docx  "application/msword" => "$imageDir/ext/file-doc.png",
        /* xsl  "application/octet-stream" => "$imageDir/ext/file-xls.png",
        /* xslx  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" => "$imageDir/ext/file-xls.png",
        /* ppt  "application/vnd.ms-powerpoint" => "$imageDir/ext/file-ppt.png",
        /* pptx "application/vnd.openxmlformats-officedocument.presentationml.presentation" => "$imageDir/ext/file-ppt.png",
        /* rtf  "text/rtf" => "$imageDir/ext/file-text.png",
        /* rtxt  "text/plain" => "$imageDir/ext/file-text.png",
        /* jpeg  "image/jpeg" => "$imageDir/ext/file-image.png",
        /* gif  "image/gif" => "$imageDir/ext/file-image.png",
        /* png  "image/png" => "$imageDir/ext/file-image.png",
        /* pdf  "application/pdf" => "$imageDir/ext/file-pdf.png",
        /* file  "file" => "$imageDir/ext/file.png" */
    );

    if ($array[$mime] == NULL)
        return $array['file'];
    return $array[$mime];
}

function isSupportedFormat($fileFormat) {
    $supportedFormats = array(
        "doc",
        "docx",
        "xls",
        "xlsx",
        "ppt",
        "pptx",
        "rtf",
        "rtxt",
        "txt",
        "jpeg",
        "jpg",
        "gif",
        "png",
        "pdf"
    );
    return in_array($fileFormat, $supportedFormats);
}
?>
